package cn.xspace.module.other.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cn.wt.wtutils.utils.ToastUtils;

import cn.xspace.module.other.R;

/**
 * chong.han 创建于 2017/4/10 0010.
 */
public class UserFeedbackAdapter extends BaseAdapter {
    private Context mContext;

    public UserFeedbackAdapter(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return 20;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.feedback_list_item, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.fb_item_right.setOnClickListener(listener);
        holder.fb_item_content_up.setOnClickListener(listener);
        holder.fb_item_content_down.setOnClickListener(listener);
        holder.fb_item_content_down.setOnClickListener(listener);

        return convertView;
    }

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (v.getId() == R.id.fb_item_left) {
                ToastUtils.show(mContext, "点击条目左边模块");
            } else if (v.getId() == R.id.fb_item_content_up) {
                ToastUtils.show(mContext, "点击条目右边上边文字模块");
            } else if (v.getId() == R.id.fb_item_content_down) {
                ToastUtils.show(mContext, "点击条目右边下边文字模块");
            }
        }
    };

    public static class ViewHolder {
        public View rootView;
        public ImageView fb_item_icon;
        public TextView fb_item_title;
        public TextView fb_item_text_up;
        public RelativeLayout fb_item_content_up;
        public TextView fb_item_text_down;
        public RelativeLayout fb_item_content_down;
        public LinearLayout fb_item_right;

        public ViewHolder(View rootView) {
            this.rootView = rootView;
            this.fb_item_icon = (ImageView) rootView.findViewById(R.id.fb_item_icon);
            this.fb_item_title = (TextView) rootView.findViewById(R.id.fb_item_title);
            this.fb_item_text_up = (TextView) rootView.findViewById(R.id.fb_item_text_up);
            this.fb_item_content_up = (RelativeLayout) rootView.findViewById(R.id.fb_item_content_up);
            this.fb_item_text_down = (TextView) rootView.findViewById(R.id.fb_item_text_down);
            this.fb_item_content_down = (RelativeLayout) rootView.findViewById(R.id.fb_item_content_down);
            this.fb_item_right = (LinearLayout) rootView.findViewById(R.id.fb_item_left);
        }

    }
}
